download_erlang:
  cmd.run:
    - name: |
        cd /srv/files/
        wget http://erlang.org/download/otp_src_18.3.tar.gz
    - unless: test -f /srv/files/otp_src_18.3.tar.gz

unzip_erlang:
  archive.extracted:
    - name: /opt/
    - source: /srv/files/otp_src_18.3.tar.gz
    - archive_format: tar
    - tar_options: zxvf
    - if_missing: /opt/otp_src_18.3
    - unless: test -d /opt/otp_src_18.3

install_erlang:
  cmd.run:
    - name: |
        cd /opt/otp_src_18.3
        yum -y install gcc glibc-devel make ncurses-devel openssl-devel autoconf
        ./configure && make && make install
        ln -s /usr/local/lib/erlang/bin/erl /usr/bin/.
        ln -s /usr/local/lib/erlang/bin/erl /bin/.
    - unless: ls /usr/local/bin/erl